home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Presentations / Presentations ’97 / Sessions ’97 / Multiplatform Code⁄Data Sharing / HelloBothWorlds / Libraries / GEOffscreen.cpp < prev    next >
Encoding:
Text File  |  1997-06-26  |  929 b   |  39 lines  |  [TEXT/CWIE]

  1.  
  2. // mail <chelly@eden.com> or surf http://www.eden.com/~chelly for feedback
  3. // free source code - do whatever you like with it
  4.  
  5. // uniform access to offscreen pixels on both mac and windows
  6.  
  7. #define CINTERFACE
  8.  
  9. #include "GEOffscreen.h"
  10.  
  11. #if TARGET_IS_MACOS
  12.  
  13. GEOffscreenInfo GetGEOffscreenInfo( GWorldPtr gw )
  14. {
  15.     GEOffscreenInfo info;
  16.     PixMapHandle const pm = GetGWorldPixMap( gw );
  17.     info.baseAddr = GetPixBaseAddr( pm );
  18.     info.rowBytes = (**pm).rowBytes & 0x3FFF;
  19.     info.bounds = (**pm).bounds;
  20.     OffsetRect( &info.bounds, -info.bounds.left, -info.bounds.top );
  21.     return info;
  22. }
  23.  
  24. #elif TARGET_IS_WIN95
  25.  
  26. GEOffscreenInfo GetGEOffscreenInfo( GWorldPtr gw )
  27. {
  28.     GEOffscreenInfo info;
  29.     PixMapHandle const pm = GetGWorldPixMap( gw );
  30.     info.baseAddr = (char *) pm->bmBits;
  31.     info.rowBytes = pm->bmInfo.bmiHeader.biWidth;
  32.     info.bounds = gw->portRect;
  33.     OffsetRect( &info.bounds, -info.bounds.left, -info.bounds.top );
  34.     return info;
  35. }
  36.  
  37. #endif
  38.  
  39.